@echo off
setlocal

:main
cls
echo.
echo ===============================
echo   Star Go App Management Tool
echo ===============================
echo.
echo Options:
echo.
echo [1] Database Migration
echo [2] Create Super Admin  
echo [3] List Users
echo [4] Change Password
echo [5] Clear Expired Tokens
echo [6] Clear All Tokens
echo [7] Reset Database
echo [8] Create New App
echo [9] List Apps
echo [0] Exit
echo.

set /p choice=Enter your choice: 

if "%choice%"=="1" (
    echo.
    echo Executing database migration...
    go run cmd/manage.go db migrate
    echo.
    pause
    goto :main
)

if "%choice%"=="2" (
    echo.
    echo Creating super administrator...
    go run cmd/manage.go user create-superuser
    echo.
    pause
    goto :main
)

if "%choice%"=="3" (
    echo.
    echo Listing all users...
    go run cmd/manage.go user list
    echo.
    pause
    goto :main
)

if "%choice%"=="4" (
    echo.
    echo Changing user password...
    go run cmd/manage.go user change-password
    echo.
    pause
    goto :main
)

if "%choice%"=="5" (
    echo.
    echo Clearing expired tokens...
    go run cmd/manage.go token clear-expired
    echo.
    pause
    goto :main
)

if "%choice%"=="6" (
    echo.
    echo Clearing all tokens...
    go run cmd/manage.go token clear-all
    echo.
    pause
    goto :main
)

if "%choice%"=="7" (
    echo.
    echo Resetting database ^(WARNING!^)...
    go run cmd/manage.go db reset
    echo.
    pause
    goto :main
)

if "%choice%"=="8" (
    echo.
    echo Creating new application...
    go run cmd/manage.go app create
    echo.
    pause
    goto :main
)

if "%choice%"=="9" (
    echo.
    echo Listing applications...
    go run cmd/manage.go app list
    echo.
    pause
    goto :main
)

if "%choice%"=="0" (
    echo.
    echo Goodbye!
    exit /b 0
)

echo.
echo Invalid choice! Please try again.
ping 127.0.0.1 -n 2 >nul
goto :main 